Merge several mp4 video using ffmpeg and php [on hold]
Posted
by
rihab
on Super User
See other posts from Super User
or by rihab
Published on 2013-11-08T13:32:24Z
Indexed on
2013/11/08
16:00 UTC
Read the original article
Hit count: 230
I would like to merge several videos using ffmpeg and php. I want to retrieve the names of the videos dynamically but I can't merge all the videos together I only get i-1 merged videos This is the code I use:
<?php
$checkBox = $_POST['language'];
$output=rand();
function conv($checkBox){
$tab=array();
for($i=0; $i<sizeof($checkBox); $i++)
{
$intermediate=rand();
$tab[$i]=$intermediate;
exec("C:\\ffmpeg\\bin\\ffmpeg -i C:\\wamp\\www\\video_qnb\\model\\input\\$checkBox[$i].mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts C:\\wamp\\www\\video_qnb\\model\\output\\$intermediate.ts");
}
return $tab;
}
$t=conv($checkBox);
for($i=0;$i<sizeof($t); $i++)
{
if($i!=0)
{
if(sizeof($t)<=2)
{
exec('C:\\ffmpeg\\bin\\ffmpeg -i "concat:C:\\wamp\\www\\video_qnb\\model\\output\\'.$t[$i-1].'.ts|C:\\wamp\\www\\video_qnb\\model\\output\\'.$t[$i].'.ts" -c copy -bsf:a aac_adtstoasc C:\\wamp\\www\\video_qnb\\model\\output\\'.$output.'.mp4');
}
else
{
exec('C:\\ffmpeg\\bin\\ffmpeg -i "concat:C:\\wamp\\www\\video_qnb\\model\\output\\'.$t[$i-1].'.ts|C:\\wamp\\www\\video_qnb\\model\\output\\'.$t[$i].'.ts" -c copy -bsf:a aac_adtstoasc C:\\wamp\\www\\video_qnb\\model\\output\\'.$output.'.mp4');
exec("C:\\ffmpeg\\bin\\ffmpeg -i C:\\wamp\\www\\video_qnb\\model\\output\\".$output.".mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts C:\\wamp\\www\\video_qnb\\model\\output\\i.ts");
exec('C:\\ffmpeg\\bin\\ffmpeg -i "concat:C:\\wamp\\www\\video_qnb\\model\\output\\i.ts|C:\\wamp\\www\\video_qnb\\model\\output\\'.$t[$i+1].'.ts" -c copy -bsf:a aac_adtstoasc C:\\wamp\\www\\video_qnb\\model\\output\\final.mp4');
$i++;
}
}
}
?>
Can anyone help me??
© Super User or respective owner